{extend name="base"}
{block name="title"}
点赚金-后台管理-订单管理
{/block}
{block name="pageName"}
已完成订单列表
{/block}
{block name="pageBody"}
<!-- 一个表格 -->
<div class="btn-toolbar">
    <button class="btn btn-success" onclick="javascript:location.reload()">刷新</button>
  <div class="btn-group">
  </div>
</div>
<div class="well">
    <table class="table">
      <thead>
        <tr>
			<th>#</th>
			<th>商品名</th>
			<th>用户名</th>
			<th>商品数量</th>
			<th>订单价格</th>
			<th>下单时间</th>
          	<th style="width: 26px;"></th>
        </tr>
      </thead>
      <tbody id="orders">
        {volist name='orders' id='order'}
		<tr id="{$order.order_id}">
			<th scope="row">{$i}</th>
			<td onclick="getCommodityInfo('{$order.commodity_id}')">
				<a href="#" style="color: blue">{$order.commodity_name}</a>
			</td>
			<td>{$order.user_name}</td>
			<td>{$order.commodity_num}</td>
			<td>{$order.order_price} 元</td>
			<td>{$order.gmt_create}</td>
		</tr>
		{/volist}
      </tbody>
    </table>
</div>
<div class="pagination">
    {$orders->render()}
</div>

<!-- 进行状态修改的jQuery函数 -->

{/block}
<!-- 一个表格结束 -->
{block name="model"}
	<script>
		function getCommodityInfo(commodity_id){
			$.getJSON("{:url('admin/commoditydo/getCommodityInfo')}",{commodity_id:commodity_id},function(data){
				var commodity = data.data;
				$("#CommodityInfo input[name='commodity_name']").val(commodity.commodity_name);
				$("#CommodityInfo input[name='commodity_price']").val(commodity.commodity_price);
				$("#CommodityInfo input[name='commodity_num']").val(commodity.commodity_num);
				$("#CommodityInfo input[name='commodity_type']").val(commodity.category_name);
				$("#CommodityInfo input[name='commodity_addr']").val(commodity.commodity_addr);
				getPics(commodity_id);
				$('#commodity_Info').modal('show');
			})
		}

		function getPics(commodity_id){
		$.getJSON("{:url('admin/commoditydo/getCommodityPic')}",{commodity_id:commodity_id},function(data){
			$("#Pics").html("");
			if(0 == data.code){
				var pictures = data.data;
				for(var i=0;i<pictures.length;i++){
					$("#Pics").append("<li><img style='width:100px' src='"+pictures[i].picture_address+"'></li>");
				}
				$('#show_pic').modal('show');
			}else{
				alert("获取图片失败");
			}
		});
	}
	</script>
	<div id="commodity_Info" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">商品信息</h3>
		</div>
		<form id="CommodityInfo" class="form-horizontal" onsubmit="return false;">
			<br>
			<div class="control-group">
	            <label class="control-label">商品名称</label>
	            <div class="controls">
	              <input type="text" name="commodity_name" placeholder="请输入商品名称" required><br>
	        	</div>
	        </div>
	        <div class="control-group">
	            <label class="control-label">商品价格</label>
	            <div class="controls">
	              <input type="number" name="commodity_price" min="0.00" step="0.01" required> 元<br>
	        	</div>
	        </div>
			<div class="control-group">
	            <label class="control-label">商品数量</label>
	            <div class="controls">
	              <input type="number" name="commodity_num" required><br>
	        	</div>
	        </div>
	        <div class="control-group">
	            <label class="control-label">商品类别</label>
	            <div class="controls">
	              <input type="text" name="commodity_type"><br>
	        	</div>
	        </div>
			<div class="control-group">
	            <label class="control-label">商品地址</label>
	            <div class="controls">
	              <input type="text" name="commodity_addr" placeholder="请输入商品地址" required><br>
	        	</div>
	        </div>
	        <div class="control-group">
	        	<label class="control-label">商品图片</label>
	            <div class="controls">
	              	 <ul id="Pics" >
	        		</ul>
	        	</div>
	        </div>
		</form>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
		</div>
	</div>
{/block}